﻿using SIAKADCORE.Helpers;
using SIAKADCORE.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SIAKADCORE.Controllers
{
    public static class LogController
    {
        public static bool Tambah(Log log)
        {
            string queryString = string.Format("INSERT INTO {0} ({1},{2}) VALUES ('{3}','{4}')",
                Log.TableName, Log.ColumnNameIdLog, Log.ColumnNameIsiLog,log.IdLog, log.IsiLog);
            return SQLHelper.Instance.ExecuteNonQuery(queryString);
        }

        public static bool GetTabel(out DataSet dataset)
        {
            string queryString = string.Format("SELECT {0},{1} FROM {2}",
                Log.ColumnNameIdLog, Log.ColumnNameIsiLog, Log.TableName);
            return SQLHelper.Instance.ExecuteReader(queryString, out dataset);
        }

       
        // GET ID
        public static string GetID()
        {
            var dataset = new DataSet();
            {
                var Dataset = new DataSet();
                bool isQueryAccomplished = GetTabel(out dataset);
                if (!isQueryAccomplished) return string.Empty;

                return SQLHelper.Instance.GetID(Log.IdPrefix, Log.IdLength, ref dataset);
            }

        }

        internal static bool Hapus(Log log)
        {
            throw new NotImplementedException();
        }
    }
}
